package org.judking.CarKeeper.activity;

import org.judking.CarKeeper.R;
import org.judking.CarKeeper.command.EarlyWarning.SpeedCrashAlarm;
import org.judking.CarKeeper.service.EarlyWarningService;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class SpeedCrashActivity extends Activity	{
	Thread waitingThread;
	
	public SpeedCrashActivity()			{
		SpeedCrashAlarm sca = new SpeedCrashAlarm();
		waitingThread = new Thread(sca); 
		EarlyWarningService.register(sca);
	}

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.speed_crash);
		
		((Button)findViewById(R.id.btn_speed_crash)).setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View arg0) {
				SpeedCrashActivity.this.waitingThread.interrupt();
				SpeedCrashActivity.this.finish();
			}
		});
		
		waitingThread.start();
	}
	
}
